package th.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;

@Entity
@Table(name = "pguna")
public class Pengguna implements Serializable {

    @Id
    @Column(name = "noKp", length = 20)
    private String noKp;
    
    @Column(name = "id_pguna", length = 30)
    private String idPengguna;
    
    @Column(name = "nama", length = 50, nullable = false)
    private String nama;
    
    @Column(name = "last_login")
//    @Temporal(TemporalType.DATE)
    private Date tarikhAkhirLogin;
    
    @Column(name = "katalaluan", length = 100)
    private String password;   
    
    @Embedded
    private InfoAudit infoAudit;
    @Column(name = "email")
    private String email;
    
    @Column(name = "phone")
    private String phone;
    
    @Column(name = "add1")
    private String add1;
    
    @Column(name = "add2")
    private String add2;
    
    @Column(name = "add3")
    private String add3;
    
    @Column(name = "add4")
    private String add4;
    
    @Column(name = "poscode")
    private String poscode;
    
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
    @JoinColumn(name = "state")
    private KodNegeri state;
    
    @Basic(optional = false)
    @Column(name = "aktif")
    private char active;
    
    @Column(name = "noPin")
    private String noPin; 
    
    @Column(name = "imgid")
    private String imgid; 
    
    //added in 2/6/2015
    @Column(name = "secPhrase")
    private String secPhrase; 
    
    @Column(name = "bil_cubaan")
    private Integer bilanganCubaan; 
    
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
    @JoinColumn(name = "kod_peranan")
    private KodPeranan jenisPengguna;
    
    @OneToMany (mappedBy = "pengguna" , fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<Akaun> senaraiAkaun;
    
    @OneToMany(mappedBy = "penggunaFav", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<AkaunFav> senaraiAkaunFav;

    public InfoAudit getInfoAudit() {
        return infoAudit;
    }

    public void setInfoAudit(InfoAudit infoAudit) {
        this.infoAudit = infoAudit;
    }

    public void setIdPengguna(String idPengguna) {
        this.idPengguna = idPengguna;
    }

    public String getIdPengguna() {
        return idPengguna;
    }

    public void setNama(String nama) {
        this.nama = nama;
    }

    public String getNama() {
        return nama;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getTarikhAkhirLogin() {
        return tarikhAkhirLogin;
    }

    public void setTarikhAkhirLogin(Date lastLoginDate) {
        this.tarikhAkhirLogin = lastLoginDate;
    }
    
    public String getAdd1() {
        return add1;
    }

    public void setAdd1(String add1) {
        this.add1 = add1;
    }

    public String getAdd2() {
        return add2;
    }

    public void setAdd2(String add2) {
        this.add2 = add2;
    }

    public String getAdd3() {
        return add3;
    }

    public void setAdd3(String add3) {
        this.add3 = add3;
    }

    public String getAdd4() {
        return add4;
    }

    public void setAdd4(String add4) {
        this.add4 = add4;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getPoscode() {
        return poscode;
    }

    public void setPoscode(String poscode) {
        this.poscode = poscode;
    }

    public KodNegeri getState() {
        return state;
    }

    public void setState(KodNegeri state) {
        this.state = state;
    }

    public char getActive() {
        return active;
    }

    public void setActive(char active) {
        this.active = active;
    }

    public String getNoKp() {
        return noKp;
    }

    public void setNoKp(String noKp) {
        this.noKp = noKp;
    }

    public String getNoPin() {
        return noPin;
    }

    public void setNoPin(String noPin) {
       this.noPin = noPin;
    }

    public List<Akaun> getSenaraiAkaun() {
        return senaraiAkaun;
    }

    public void setSenaraiAkaun(List<Akaun> senaraiAkaun) {
        this.senaraiAkaun = senaraiAkaun;
    }

    public KodPeranan getJenisPengguna() {
        return jenisPengguna;
    }

    public void setJenisPengguna(KodPeranan jenisPengguna) {
        this.jenisPengguna = jenisPengguna;
    }

    public Integer getBilanganCubaan() {
        return bilanganCubaan;
    }

    public void setBilanganCubaan(Integer bilanganCubaan) {
        this.bilanganCubaan = bilanganCubaan;
    }

    public String getImgid() {
        return imgid;
    }

    public void setImgid(String imgid) {
        this.imgid = imgid;
    }  

    public List<AkaunFav> getSenaraiAkaunFav() {
        return senaraiAkaunFav;
    }

    public void setSenaraiAkaunFav(List<AkaunFav> senaraiAkaunFav) {
        this.senaraiAkaunFav = senaraiAkaunFav;
    }

    public String getSecPhrase() {
        return secPhrase;
    }

    public void setSecPhrase(String secPhrase) {
        this.secPhrase = secPhrase;
    }

}
